#ifndef QLIB_HEADER_FLEX_ELLIPSE
#define QLIB_HEADER_FLEX_ELLIPSE

#include "qlib/core/object.h"
#include "qlib/core/vec2.h"
#include "qlib/geo/polygon.h"
#include "qlib/layout/repetition.h"
#include "qlib/layout/property.h"

namespace qlib {
class FlexEllipse;
using FlexEllipsePtrArray = std::vector<std::shared_ptr<FlexEllipse>>;

class QLIB_API FlexEllipse {
 public:
  FlexEllipse();

  using s_ptr = std::shared_ptr<FlexEllipse>;
  template <typename... Args>
  static s_ptr create(Args... args) {
    return std::make_shared<FlexEllipse>(args...);
  }
  // template <>
  static s_ptr create() {
    return std::make_shared<FlexEllipse>();
  }
  static s_ptr create(const FlexEllipse& value) { return std::make_shared<FlexEllipse>(value); }

  // 未添加rotation
  s_ptr copy() const;
  void init(Vec2d _center, Vec2d _radius, Vec2d _inner_radius, Vec2d _angle, double _tolerance = 1e-3, uint32_t _layer = 0, uint32_t _datatype = 0);

  Polygon::s_ptr to_polygon() const;
  Vec2dArray bounding_box() const;

  void scale(double sx, double sy);
  void mirror(Vec2d p0, Vec2d p1);
  void translate(double dx, double dy);
  void transform(double magnification, bool x_reflection, Vec2d origin);

  Vec2d center;
  Vec2d radius;
  Vec2d inner_radius;
  Vec2d angle;

  double tolerance;
  double rotation;

  uint32_t layer;
  uint32_t datatype;
  PropertyArray properties;
  Repetition repetition;
};

}  // namespace qlib

#endif